package longcaisuyun.longcai.com.net;

import com.zcx.helper.http.AsyCallBack;
import com.zcx.helper.http.note.HttpInlet;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

import longcaisuyun.longcai.com.suyunbean.ShopBean;

@HttpInlet(Net.SHANGPIN_4)
public class PostShangpin_4 extends WHAsyPost<PostShangpin_4.Info> {
    public String page;
    public String typeid;

    public PostShangpin_4(String page, String typeid, AsyCallBack asyCallBack) {
        super(asyCallBack);
        this.page = page;
        this.typeid = typeid;
    }


    protected Info parser(JSONObject object) {
        Info info = new Info();
        try {
            info.message = object.getString("message");
            if (info.message.equals("1")) {
                for (int j = 0; j < object.getJSONArray("list").length(); j++) {
                    ShopBean shopBean = new ShopBean();
                    shopBean.setPicurl(object.getJSONArray("list").getJSONObject(j).getString("picurl"));
                    shopBean.setTitle(object.getJSONArray("list").getJSONObject(j).getString("title"));
                    shopBean.setTypeid(object.getJSONArray("list").getJSONObject(j).getString("id"));
                    info.list.add(shopBean);
                }

            }
            info.ispage = object.getString("ispage");
            info.nextpage = object.getString("nextpage");
            return info;
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return null;
    }

    public static class Info {
        public String message;
        public List<ShopBean> list = new ArrayList<ShopBean>();
        public String nextpage;
        public String ispage;
    }
}
